<?php

namespace Eduxplus\CoreBundle\Command;

use Eduxplus\CoreBundle\Lib\Base\BaseService;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
class BeforeGenCommand extends Command
{
    protected static $defaultName = 'core:gen:before';
    /**
     * @var BaseService
     */
    private $baseService;
    /**
     * TestCommand constructor.
     */
    public function __construct(
        BaseService $baseService
    ) {
        parent::__construct();
        $this->baseService = $baseService;
    }

    protected function configure()
    {
        $this
            ->setDescription('test');
    }

    protected function execute(InputInterface $input, OutputInterface $output): int
    {
        $io = new SymfonyStyle($input, $output);
        $projectDir = $this->baseService->getBasePath();
        $lockFile = $projectDir."/.gen.lock";
        if(file_exists($lockFile)){
            $io->error("gen is locked!");
            return Command::INVALID;
        }
        return Command::SUCCESS;
    }
}
